package toubiao.service.impl;

import java.io.File;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import toubiao.exception.CustomException;
import toubiao.service.DownloadServiceI;
import toubiao.utils.ProUtilConfig;

@Service
public class DownloadServiceImpl implements DownloadServiceI {

	private Logger logger=LoggerFactory.getLogger(this.getClass());
	
	/*@Value( "${download.public}")*/
	private String publicAbsPath=ProUtilConfig.getDownloadPublicPath();
	
	/*@Value( "${download.temp}")*/
	private String tempAbsPath=ProUtilConfig.getDownloadTempPath();
	


	
	@Override
	public String getPublicFileAbsPath(String fileName) throws CustomException {
		// TODO Auto-generated method stub
		logger.info(publicAbsPath);
		logger.info(tempAbsPath);
		
		String fileAbsPath=publicAbsPath+fileName;
		File file=new File(fileAbsPath);
		if(file.exists()){
			return fileAbsPath;
		}else{
			throw new CustomException("未找到 文件名为  '"+fileName+"' 的文件 ");
		}
	}

}
